def draw_validate(f):
    def helper(self, **kwargs):
        if self._bins is None:
            msg = "Attempt to draw empty histogram `{0}'"
            raise ValueError(msg.format(self.name))

        self.flush()

        if self._tot_i == 0:
            msg = "Attempt to draw empty histogram `{0}'"
            raise ValueError(msg.format(self.name))


        return f(self, **kwargs)

    return helper


def validate_not_empty(f):
    def helper(self, *args, **kwargs):
         if self._bins is None:
             self._setup_arrays()
         else:
             self.flush()

         return f(self, *args, **kwargs)
    
    return helper
        
